<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <el-input
          v-model="query.blurry"
          clearable
          placeholder="模糊搜索"
          style="width: 200px"
          class="filter-item"
          @keyup.enter.native="crud.toQuery"
        />
        <rrOperation />
      </div>
      <crudOperation :permission="permission" />
    </div>
    <!--表格渲染-->
    <el-table
      ref="table"
      v-loading="crud.loading"
      :data="crud.data"
      style="width: 100%;"
      @selection-change="crud.selectionChangeHandler"
    >
      <el-table-column type="selection" width="55" />
      <el-table-column prop="topicName" label="Topic Name" />
      <el-table-column prop="clusterName" label="Cluster Name" />
      <el-table-column
        v-if="checkPermission(['admin', 'topic:edit', 'topic:del'])"
        label="操作"
        width="150px"
        align="center"
      >
        <template slot-scope="scope">
          <udOperation :data="scope.row" :permission="permission" />
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import crudMonitor from '@/api/mq/kafka/monitor'

const defaultForm = { }
export default {
  name: 'Consumer',
  components: { crudOperation, rrOperation, udOperation },
  cruds() {
    return CRUD({ title: 'Topic', url: 'api/mq/monitor/topic', crudMethod: { ...crudMonitor }})
  },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  data() {
    return {
      permission: {
        add: ['admin', 'topic:add'],
        edit: ['admin', 'topic:edit'],
        del: ['admin', 'topic:del']
      }
    }
  }
}
</script>
